﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：庄金冬 
    //
    // 文件名：IBLL_User.cs
    // 文件功能描述：用户接口
    // 创建标识：庄金冬2009-03-06
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
    // 审核时间：
    // 审核说明：
 //----------------------------------------------------------------*/
using System;
using System.Collections.Generic;

using System.Text;
using HZ.DrugTrade.Model;

namespace HZ.DrugTrade.IBLL
{
    /// <summary>
    /// 用户接口
    /// </summary>
    public interface IBLL_User
    {
        #region 用户操作
        /// <summary>
        /// 添加用户同时设置权限(0,添加失败;1,添加成功;2,用户编号已存在;)
        /// </summary>
        /// <param name="user">用户对象（每个用户的UserRole仅RoleID须赋值，Org仅OrgID须赋值）</param>
        /// <param name="ruleIList">操作权限集合（每个权限仅RuleID须赋值）</param>
        /// <returns>(0,添加失败;1,添加成功;2,用户编号已存在;)</returns>
        int AddUser_OperatingRule(User user, IList<OperatingRule> ruleIList);

        /// <summary>
        /// 更新用户信息[名称、是否启用](0,更新失败;1,更新成功;2,用户编号不存在;)
        /// </summary>
        /// <param name="user">用户[名称、是否启用]</param>
        /// <returns>(0,更新失败;1,更新成功;2,用户编号不存在;)</returns>
        int UpdateUser(User user);


        /// <summary>
        /// 更新用户信息[名称、是否启用]同时设置权限(0,更新失败;1,更新成功;2,用户编号不存在;)
        /// </summary>
        /// <param name="user">用户[名称、是否启用、权限集合]</param>
        /// <returns>(0,更新失败;1,更新成功;2,用户编号不存在;)</returns>
        int UpdateUserRule(User user);

        /// <summary>
        /// 设置用户的操作权限
        /// </summary>
        /// <param name="userid">用户编号</param>
        /// <param name="ruleIList">操作权限集合（每个权限仅RuleID须赋值）</param>
        /// <returns></returns>
        bool SetUserOperatingRule(string userid, IList<OperatingRule> ruleIList);


        /// <summary>
        /// 修改密码(0,更新失败;1,更新成功;2,原密码错误)
        /// </summary>
        /// <param name="userid">用户编号</param>
        /// <param name="oldpassword">原始密码</param>
        /// <param name="newpassword">新密码</param>
        /// <returns>(0,更新失败;1,更新成功;2,原密码错误)</returns>
        int UpdatePassword(string userid, string oldpassword, string newpassword);

        /// <summary>
        /// 密码初始化
        /// </summary>
        /// <param name="userid">用户编号</param>
        /// <param name="newpassword">初始化密码</param>
        /// <returns></returns>
        bool InitPassword(string userid, string newpassword);

         /// <summary>
        /// 密码初始化
        /// </summary>
        /// <param name="userid">用户编号</param>
        /// <param name="newpassword">初始化密码</param>
        /// <returns></returns>
        bool InitPassword(IList<User> lst);

        /// <summary>
        /// 密码初始化
        /// </summary>
        /// <param name="userids">用户编号集合</param>
        /// <param name="newpassword">初始化密码</param>
        /// <returns></returns>
        bool InitPassword(List<string> userids, string newpassword);


        /// <summary>
        /// 用户锁定
        /// </summary>
        /// <param name="userid">用户编号</param>
        /// <returns></returns>
        bool LockUser(string userid);

        /// <summary>
        /// 用户解锁
        /// </summary>
        /// <param name="userid">用户编号</param>
        /// <returns></returns>
        bool UnblockUser(string userid);


        /// <summary>
        /// 用户锁定（批量）
        /// </summary>
        /// <param name="userids">用户编号集合</param>
        /// <returns></returns>
        bool LockUser(List<string> userids);

        /// <summary>
        /// 用户解锁（批量）
        /// </summary>
        /// <param name="userids">用户编号集合</param>
        /// <returns></returns>
        bool UnblockUser(List<string> userids);

        /// <summary>
        /// 删除用户(0,删除失败;1,删除成功;2,该用户不存在;)
        /// </summary>
        /// <param name="userid">用户编号</param>
        /// <returns>(0,删除失败;1,删除成功;2,该用户不存在;)</returns>
        int DeleteUser(string userid);


        /// <summary>
        /// 授权医疗机构入围(0,失败;1,成功;)
        /// </summary>
        /// <param name="userIDs">主用户编号集合（如：1,2,3）</param>
        /// <param name="operatingRuleID">操作编号</param>
        /// <returns>(0,失败;1,成功;)</returns>
        int AuthorizeHospitalCatalogManageRule(string userIDs, string operatingRuleID);

        /// <summary>
        /// 撤权医疗机构入围(0,失败;1,成功;)
        /// </summary>
        /// <param name="userIDs">主用户编号集合（如：1,2,3）</param>
        /// <param name="operatingRuleID">操作编号</param> 
        /// <returns>(0,失败;1,成功;)</returns>
        int RevokeHospitalCatalogManageRule(string userIDs, string operatingRuleID);

        /// <summary>
        /// 授权(0,失败;1,成功;)
        /// </summary>
        /// <param name="Orgs">机构字典(key:OrgID,value:RoleID)</param>
        /// <returns>(0,失败;1,成功;)</returns>
        int AuthorizeOrg(IDictionary<string, string> Orgs);

        /// <summary>
        /// 撤权(0,失败;1,成功;)
        /// </summary>
        /// <param name="Orgs">机构字典(key:OrgID,value:RoleID)</param>
        /// <returns>(0,失败;1,成功;)</returns>
        int RevokeOrg(IDictionary<string, string> Orgs);

        #endregion

        #region 用户查询
        /// <summary>
        /// 获取所有用户
        /// </summary>
        /// <param name="currentPage">当前页</param>
        /// <param name="pageSize">每页显示记录数</param>
        /// <param name="totalRecord">（输出参数）总记录数目</param>
        /// <returns>用户集合</returns>
        IList<User> GetAllUser(int currentPage, int pageSize, out int totalRecord);

        /// <summary>
        /// 按角色获取所有主用户
        /// </summary>
        /// <param name="role">角色（Role仅RoleID须赋值）</param>
        /// <param name="currentPage">当前页</param>
        /// <param name="pageSize">每页显示记录数</param>
        /// <param name="totalRecord">（输出参数）总记录数目</param>
        /// <returns>主用户集合（不含权限角色等相关信息）</returns>
        IList<User> GetAllUserByRole(Role role, int currentPage, int pageSize, out int totalRecord);

        /// <summary>
        /// 根据编号获取用户（不含权限信息，角色信息，权限信息，机构信息）
        /// </summary>
        /// <param name="userid">用户编号</param>
        /// <returns></returns>
        User GetUserByUserID(string userid);


        /// <summary>
        /// 根据编号获取用户（包含用户信息，角色信息，权限信息，机构信息）
        /// </summary>
        /// <param name="userid">用户编号</param>
        /// <returns></returns>
        User GetUserInfoByUserID(string userid);


        /// <summary>
        ///  获取某个主用户的子用户
        /// </summary>
        /// <param name="userid">主用户编号</param>
        /// <returns>用户集合</returns>
        IList<User> GetChildUserByUserID(string userid);




        /// <summary>
        /// 获取用户的操作权限
        /// </summary>
        /// <param name="userid">用户编号</param>
        /// <returns>操作权限集合</returns>
        IList<OperatingRule> GetUserOperatingRule(string userid);



        /// <summary>
        /// 条件查询
        /// </summary>
        /// <param name="user">查询用实体</param>
        /// <param name="currentPage">当前页</param>
        /// <param name="pageSize">每页显示记录数</param>
        /// <param name="totalRecord">（输出参数）总记录数目</param>
        /// <returns></returns>
        IList<User> GetUserByWhere(HZ.DrugTrade.Model.Query.User user, int currentPage, int pageSize, out int totalRecord);

        /// <summary>
        /// 条件机构用户查询（含机构角色相关信息）
        /// </summary>
        /// <param name="user">查询用实体</param>
        /// <param name="currentPage">当前页</param>
        /// <param name="pageSize">每页显示记录数</param>
        /// <param name="totalRecord">（输出参数）总记录数目</param>
        /// <returns></returns>
        IList<HZ.DrugTrade.Model.View.OrgUsers> GetOrgUsersByWhere(HZ.DrugTrade.Model.Query.OrgUsers user, int currentPage, int pageSize, out int totalRecord);


        /// <summary>
        /// 条件医疗机构用户查询（含机构角色相关信息）
        /// </summary>
        /// <param name="user">查询用实体</param>
        /// <param name="currentPage">当前页</param>
        /// <param name="pageSize">每页显示记录数</param>
        /// <param name="totalRecord">（输出参数）总记录数目</param>
        /// <returns></returns>
        IList<HZ.DrugTrade.Model.View.HospitalUsers> GetHospitalUsersByWhere(HZ.DrugTrade.Model.Query.HospitalUsers user, int currentPage, int pageSize, out int totalRecord);


        /// <summary>
        /// 条件医疗机构入围授权查询
        /// </summary>
        /// <param name="user">查询用实体</param>
        /// <param name="currentPage">当前页</param>
        /// <param name="pageSize">每页显示记录数</param>
        /// <param name="totalRecord">（输出参数）总记录数目</param>
        /// <returns></returns>
        IList<HZ.DrugTrade.Model.View.HospitalCatalogManageRule> GetHospitalCatalogManageRulesByWhere(HZ.DrugTrade.Model.Query.HospitalCatalogManageRule user, int currentPage, int pageSize, out int totalRecord);
        /// <summary>
        /// 根据用户ID获取主用户信息
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        User GetAdminUserByID(string userid);
        #endregion
    }
}
